package com.example.es.controller;

import cn.hutool.core.lang.UUID;

import java.text.SimpleDateFormat;
import java.time.*;
import java.util.*;
import java.util.logging.SimpleFormatter;
import java.util.stream.Collectors;
import java.util.stream.Stream;

public class TestDemo3 {

    public static void main(String[] args) {
        System.out.println(new SimpleDateFormat("yyyy-MM-dd HH-mm-ss").format(new Date()));
    }
    public static void main10(String[] args) {
//        Random random = new Random();
//        int i = random.nextInt(10 + 1);
//        Scanner scanner = new Scanner(System.in);
//        int i1 = scanner.nextInt();
//        if(i == i1) {
//            System.out.println("真厉害");
//        } else {
//            System.out.println("猜错了，值为"+i);
//        }
        System.out.println(UUID.randomUUID().toString().replace("-", " "));
    }
    public static void main9(String[] args) {
        int[] intArray = {1, 2, 3, 4, 5};
        Arrays.stream(Arrays.copyOf(intArray, 3)).filter(s -> s == 1 || s == 2).forEach(System.out::println);

    }
    public static void main8(String[] args) {
        LocalDateTime localDateTime = LocalDateTime.now().withNano(0);
        System.out.println(localDateTime);
        Duration duration = Duration.ofMillis(1);
        System.out.println(duration.getSeconds());
        Period period = Period.ofDays(10);
        LocalDateTime localDateTime1 = localDateTime.plusHours(3);
        System.out.println(localDateTime1);
        LocalDateTime plus = localDateTime.plus(period);
        System.out.println(plus);
    }
    public static void main7(String[] args) {
        // 获取当前日期
        LocalDateTime currentDate = LocalDateTime.now().withNano(0);

        // 计算十天后的日
        Period tenDaysLater = Period.ofDays(10);
        LocalDateTime tenDaysAfter = currentDate.plus(tenDaysLater);

        // 输出结果
        System.out.println("Current date: " + currentDate);
        System.out.println("Ten days later: " + tenDaysAfter);
    }
    public static void main6(String[] args) {
        LocalDateTime localDateTime = LocalDateTime.now().withNano(0);
        System.out.println(localDateTime);
        System.out.println(localDateTime.toString().replace("T", " "));

    }
    public static void main5(String[] args) {
        boolean b = Stream.of("1", "2", "3").map(Integer::parseInt).noneMatch(s -> s > 2);
        System.out.println(b);
        int[] arr = new int[]{1,2,3};
        Optional<Integer> max1 = Stream.of("1", "2", "3").map(Integer::parseInt).max((o1, o2) -> o2 - o1);
        System.out.println(max1.get());
    }
    public static void main4(String[] args) {
        List<String> list = Arrays.asList("123", "25", "36");
        List<Integer> collect = list.stream().map(Integer::parseInt).sorted((o1, o2) -> o2-o1).collect(Collectors.toList());
        collect.stream().forEach(System.out::println);
        System.out.println("--------");
        Stream.of(
                        "1","2","1"
                ).distinct()
                .forEach(System.out::println);
    }
    public static void main3(String[] args) {
        List<String> list = Arrays.asList("张三", "张三丰", "张龙", "周星驰");
        list.stream().filter(s -> s.startsWith("张"))
                .skip(1)
                .forEach(System.out::println);
    }
    public static void main2(String[] args) {
//        Map<String,Object> map = new HashMap<>();
//        Stream<String> stream = map.keySet().stream();
//        Stream<Object> stream1 = map.values().stream();
//        Stream<Map.Entry<String, Object>> stream2 = map.entrySet().stream();
        Stream<String> a1 = Stream.of("a1","a2","a3");
        String[] arr1 = {"aa","bb","cc"};
        Stream<String> arr11 = Stream.of(arr1);


        Integer[] arr2 = {1,2,3,4};
        Stream<Integer> arr21 = Stream.of(arr2);
        long count = Stream.of(arr2).count();
        System.out.println(count);
        Stream.of(arr2).forEach(System.out::println);
        // 注意：基本数据类型的数组是不行的
        int[] arr3 = {1,2,3,4};
        Stream.of(arr3).forEach(System.out::println);

    }
    public static void main1(String[] args) {
        System.out.println(UUID.randomUUID().toString().replace("-", "-").length());
    }
}
